<?php
 
namespace Piwik\Plugins\AdsPlace\Lib;
 
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Exception\RequestException;

/**
 * Description of Request
 *
 * @author Dell
 */
class ApiRequest {

    private $client;

    function __construct($options) {
        $options['verify']= false;
        $this->client = new HttpClient($options);
    }
    /**
     * 可以捕获异常报错信息 返回
     * @param type $method
     * @param type $uri
     * @param type $params
     * @return GuzzleHttp\Response $response
     */
    public function api_request($method, $uri, $params) {
        try {
            $response = $this->client->request(
                    $method, $uri, $params
            );
        } catch (RequestException $e) {    
             
            if ($e->hasResponse()) {
                return $e->getResponse();
            }
            $response = $e->getRequest();
        }
        return $response;
    }

    public function __call($name, $arguments) {
        return $this->client->$name($arguments);
    }

}

